package com.example.demo2.config;

import com.example.demo2.util.RabbitMqUtils;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ToicRabbitMqConfigation {
    //创建交换机 路由模式
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(RabbitMqUtils.TOIC_EXCHANGE,true,false);
    }
    //创建队列
    @Bean
    public Queue weixin_toic(){
        return new Queue("weixin_toic",true);
    }
    @Bean
    public Queue email_toic(){
        return new Queue("email_toic",true);
    }
    @Bean
    public Queue qq_toic(){
        return new Queue("qq_toic",true);
    }
    //队列绑定交换机
    @Bean
    public Binding binding31(){
        return BindingBuilder.bind(weixin_toic()).to(topicExchange()).with("#.direct_weixin.*");
    }
    @Bean
    public Binding binding32(){
        return BindingBuilder.bind(email_toic()).to(topicExchange()).with("com.direct_email.#");
    }
    @Bean
    public Binding binding33(){
        return BindingBuilder.bind(qq_toic()).to(topicExchange()).with("#.direct_qq.#");
    }
}
